home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 2.3 KB | 76 lines | [TEXT/CWIE] |
- {
- File: readLocation.p
-
- Contains: retrieves the map settings for longitude and latitude and
- the time offset from GMT
-
- for more information, see Worldwide Development: Guide to System Software
-
- Written by: Greg Robbins
-
- Copyright: Copyright © 1991-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/9/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- }
-
- PROGRAM location;
-
- USES Types, Script, FixMath;
-
- VAR
- myMachineLocation: MachineLocation;
- latExt, longExt: EXTENDED;
- latDeg, latMin, longDeg, longMin: LONGINT;
- theGmtDelta, hours, minutes, seconds: LONGINT;
-
- FUNCTION GetGmtDelta(myLocation: MachineLocation): LONGINT;
- VAR
- internalGmtDelta: LONGINT;
- BEGIN
- { change 3-byte integer to LONGINT }
- internalGmtDelta := BAND(myLocation.gmtDelta,$00FFFFFF);
- IF BTST(internalGmtDelta,23) THEN { sign extend }
- internalGmtDelta := BOR(internalGmtDelta,$FF000000);
- GetGmtDelta := internalGmtDelta;
- END;
-
- BEGIN
- ReadLocation(myMachineLocation);
-
- { convert location to extended fraction }
- latExt := Frac2X(myMachineLocation.latitude);
- longExt := Frac2X(myMachineLocation.longitude);
-
- { convert location to degrees-minutes }
- latDeg := TRUNC(latExt * 90);
- latMin := TRUNC((latExt * 90 - latDeg) * 60);
-
- longDeg := TRUNC(longExt * 90);
- longMin := TRUNC((longExt * 90 - longDeg) * 60);
-
- { find time zone w.r.t. GMT }
- theGmtDelta := GetGmtDelta(myMachineLocation);
- hours := theGmtDelta DIV 3600;
- minutes := (theGmtDelta MOD 3600) DIV 60;
- seconds := theGmtDelta MOD 60;
-
- { negative values indicate South or West }
- WriteLn('latitude: ', latDeg, CHR($A1), latMin, CHR($27));
- WriteLn('longitude: ', longDeg, CHR($A1), longMin, CHR($27));
-
- { negative values indicate West }
- WriteLn('time from GMT: ', hours:3, ' h ', minutes:3, ' m ',
- seconds:2, ' s');
- END.
-